package com.git.plane;

import java.util.Random;

/**
 * 蜜蜂类，蜜蜂是奖励，即是飞行物，也是奖励
 * 
 * @author lichao
 *
 * @date 2016年3月14日
 */
public class Bee extends FlyingObject implements Award {

	private int xSpeed = 1;// x坐标移动速度
	private int ySpeed = 2;// y坐标移动速度

	private int awardType; // 奖励类型

	public Bee() {
		this.image = ShootGame.bee;
		this.width = image.getWidth();
		this.height = image.getHeight();
		y = -height;

		Random random = new Random();
		x = random.nextInt(ShootGame.WIDTH - this.width);// x的位置随机，在0到边框-蜜蜂长度的范围内
		// y = 200;
		// x = 200;
		awardType = random.nextInt(2);// 随机奖励
	}

	@Override
	public int getType() {
		return 0;
	}

	/**
	 * 蜜蜂的飞行可以是斜的
	 * 
	 * 当蜜蜂到达最右端时，让其向左移动，当到达最左边时向右移动
	 */
	@Override
	void step() {
		this.x += xSpeed;
		this.y += ySpeed;
		if (this.x > ShootGame.WIDTH - width) {
			xSpeed = -1;
		}
		if (this.x < 0) {
			xSpeed = 1;
		}
	}

}
